<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="Cask Data, Inc." name="author" />
<meta content="Copyright © 2017 Cask Data, Inc." name="copyright" />


    <meta name="git_release" content="6.1.1">
    <meta name="git_hash" content="05fbac36f9f7aadeb44f5728cea35136dbc243e5">
    <meta name="git_timestamp" content="2020-02-09 08:22:47 +0800">
    <title>CDAP Replication</title>

    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-dynamicscrollspy-4.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/abixTreeList-2.css" type="text/css" />
    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '6.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>

    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="Cask Data Application Platform 6.1.1 Documentation" href="../index.html" />
    <link rel="up" title="Installation" href="index.html" />
    <link rel="next" title="&lt;no title&gt;" href="cdap-site.html" />
    <link rel="prev" title="Manual Installation using Packages" href="packages.html" />
    <!-- block extrahead -->
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <!-- block extrahead end -->

</head>
<body role="document">

<!-- block navbar -->
<div id="navbar" class="navbar navbar-inverse navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="row">
        <div class="navbar-header">
          <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
          <a class="navbar-brand" href="../table-of-contents/../../index.html">
            <span><img alt="CDAP logo" src="../_static/cdap_logo.svg"/></span>
          </a>

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

          <div class="pull-right">
            <div class="dropdown version-dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                role="button" aria-haspopup="true" aria-expanded="false">
                v 6.1.1 <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="//docs.cdap.io/cdap/5.1.2/en/index.html">v 5.1.2</a></li>
                <li><a href="//docs.cdap.io/cdap/4.3.4/en/index.html">v 4.3.4</a></li>
              </ul>
            </div>
          </div>
          <form class="navbar-form navbar-right navbar-search" action="../search.html" method="get">
            <div class="form-group">
              <div class="navbar-search-image material-icons"></div>
              <input type="text" name="q" class="form-control" placeholder="  Search" />
            </div>
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>

          <div class="collapse navbar-collapse nav-collapse navbar-right navbar-navigation">
            <ul class="nav navbar-nav"><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../index.html">简介</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link current" href="../table-of-contents/../../guides.html">手册</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../reference-manual/index.html">参考</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../faqs/index.html">帮助</a></li>
            </ul>
          </div>

        </div>
      </div>
    </div>
  </div><!-- block navbar end -->
<!-- block main content -->
<div class="main-container container">
  <div class="row"><div class="col-md-2">
      <div id="sidebar" class="bs-sidenav scrollable-y-outside" role="complementary">
<!-- theme_manual: admin-manual -->
<!-- theme_manual_highlight: guides -->
<!-- sidebar_title_link: ../table-of-contents/../../guides.html -->

  <div role="note" aria-label="manuals links"><h3><a href="../table-of-contents/../../guides.html">Guides</a></h3>

    <ul class="this-page-menu">
      <li class="toctree-l1"><a href="../table-of-contents/../../user-guide/index.html" rel="nofollow">用户手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../developer-manual/index.html" rel="nofollow">开发手册</a>
      </li>
      <li class="toctree-l1"><b><a href="../table-of-contents/../../admin-manual/index.html" rel="nofollow">管理手册</a></b>
      <nav class="pagenav">
      <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html"> Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cdap-components.html"> CDAP Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../deployment-architectures.html"> Deployment Architectures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../hadoop-compatibility.html"> Hadoop Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cdap-hadoop-compatibility.html"> CDAP and Hadoop Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../system-requirements.html"> System Requirements</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html"> Installation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="cloudera.html">Cloudera Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="emr.html">Amazon EMR</a></li>
<li class="toctree-l2"><a class="reference internal" href="ambari.html">Apache Ambari</a></li>
<li class="toctree-l2"><a class="reference internal" href="mapr.html">MapR</a></li>
<li class="toctree-l2"><a class="reference internal" href="azure-hdinsight.html">Microsoft Azure HDInsight</a></li>
<li class="toctree-l2"><a class="reference internal" href="packages.html">Packages</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Replication</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../incompatibilities.html"> Incompatibilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../upgrading/index.html"> Upgrading</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/cloudera.html">Cloudera Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/ambari.html">Apache Ambari</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/mapr.html">MapR</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/packages.html">Packages</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../security/index.html"> Security</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../security/perimeter-security.html">Perimeter Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/authorization.html">Authorization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/impersonation.html">Impersonation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/system-services.html">Enabling SSL for System Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/secure-storage.html">Secure Storage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../operations/index.html"> Operations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../operations/logging.html"> Logging and Monitoring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/metrics.html"> Metrics</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/operations-dashboard.html"> Dashboard and Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/preferences.html"> Preferences and Runtime Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/scaling-instances.html"> Scaling Instances</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/resource-guarantees.html"> Resource Guarantees in YARN</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/tx-maintenance.html"> Transaction Service Maintenance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/cdap-ui.html"> CDAP UI</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../appendices/index.html"> Appendices</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../appendices/cdap-site.html"> Appendix: cdap-site.xml</a></li>
<li class="toctree-l2"><a class="reference internal" href="../appendices/cdap-security.html"> Appendix: cdap-security.xml</a></li>
<li class="toctree-l2"><a class="reference internal" href="../appendices/minimal-cdap-site.html"> Appendix: Minimal cdap-site.xml</a></li>
<li class="toctree-l2"><a class="reference internal" href="../appendices/hbase-ddl-executor.html"> Appendix: HBaseDDLExecutor</a></li>
</ul>
</li>
</ul>
</nav>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../integrations/index.html" rel="nofollow">集成手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../examples-manual/index.html" rel="nofollow">最佳实践</a>
      </li>
    </ul>
  </div></div>
    </div><div class="col-md-8 content" id="main-content">
    
  <div class="section" id="cdap-replication">
<span id="installation-replication"></span><h1>CDAP Replication<a class="headerlink" href="#cdap-replication" title="Permalink to this headline">🔗</a></h1>
<p>This document lists the detailed steps required for setting up CDAP replication, where one
CDAP cluster (a <em>master</em>) is replicated to one or more additional CDAP <em>slave</em> clusters.</p>
<p><strong>Note:</strong> As described below, CDAP must have <a class="reference internal" href="#installation-replication-disable-invalid-transaction-list-pruning"><span class="std std-ref">invalid transaction list pruning disabled</span></a>, as this cannot be
used with replication.</p>
<p><strong>These steps should be reviewed (and the</strong> <a class="reference internal" href="#cluster-setup">Cluster Setup</a> <strong>completed) prior to starting CDAP.</strong></p>
<div class="section" id="cluster-setup">
<span id="installation-replication-cluster-setup"></span><h2>Cluster Setup<a class="headerlink" href="#cluster-setup" title="Permalink to this headline">🔗</a></h2>
<p>CDAP replication relies on the cluster administrator setting up replication on <a class="reference internal" href="#hbase">HBase</a>,
<a class="reference internal" href="#hdfs">HDFS</a>, <a class="reference internal" href="#hive">Hive</a>, and <a class="reference internal" href="#kafka">Kafka</a>.</p>
<ul class="simple">
<li>It is assumed that CDAP is only running on the master cluster.</li>
<li>It is assumed that <strong>you have not started CDAP before any of these steps</strong>.</li>
</ul>
<div class="section" id="hbase">
<h3>HBase<a class="headerlink" href="#hbase" title="Permalink to this headline">🔗</a></h3>
<ul>
<li><p class="first">Install the relevant <code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat</span></code> package on all HBase nodes of your cluster in order
to use the replication status coprocessors. Note that due to HBase limitations, these
coprocessors cannot be used on HBase 0.96 or 0.98.</p>
<p>Available “compat” packages are:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat-1.0</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat-1.0-cdh</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat-1.0-cdh5.5.0</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat-1.1</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">cdap-hbase-compat-1.2-cdh5.7.0</span></code></li>
</ul>
<p><em>Note:</em> For Cloudera Manager, all of these packages will be installed in your “Parcel Directory”
and as described below, you will add the appropriate one to your <code class="docutils literal notranslate"><span class="pre">HBASE_CLASSPATH</span></code>.</p>
</li>
</ul>
<ul>
<li><p class="first">Modify <code class="docutils literal notranslate"><span class="pre">hbase-site.xml</span></code> on all HBase nodes to enable HBase replication, and to use the
CDAP replication status coprocessors:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>hbase.replication<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>true<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>hbase.coprocessor.regionserver.classes<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>io.cdap.cdap.data2.replication.LastReplicateTimeObserver<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>hbase.coprocessor.wal.classes<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>io.cdap.cdap.data2.replication.LastWriteTimeObserver<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
</pre></div>
</div>
</li>
</ul>
<ul>
<li><p class="first">Modify <code class="docutils literal notranslate"><span class="pre">hbase-env.sh</span></code> on all HBase nodes to include the HBase coprocessor in the classpath:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">export HBASE_CLASSPATH=&quot;$HBASE_CLASSPATH:/&lt;cdap-home&gt;/&lt;hbase-compat-version&gt;/coprocessor/*&quot;</span>

<span class="gp">#</span> &lt;cdap-home&gt; will vary depending on your distribution and installation
<span class="gp">#</span> For Cloudera Manager/CDH: it is <span class="s2">&quot;</span><span class="si">${</span><span class="nv">PARCEL_ROOT</span><span class="si">}</span><span class="s2">/CDAP&quot;</span> where <span class="si">${</span><span class="nv">PARCEL_ROOT</span><span class="si">}</span> is your configured <span class="s2">&quot;Parcel Directory&quot;</span>
<span class="gp">#</span> Ambari/HDP, MapR, packages: it is <span class="s2">&quot;/opt/cdap&quot;</span>
<span class="gp">#</span>
<span class="gp">#</span> &lt;hbase-compat-version&gt; is the HBase package compatible with the distribution

<span class="gp">#</span> For example, <span class="k">if</span> you are on a Cloudera Manager cluster with CDH <span class="m">5</span>.5.x:
<span class="go">export HBASE_CLASSPATH=&quot;$HBASE_CLASSPATH:/opt/cloudera/parcels/CDAP/hbase-compat-1.0-cdh5.5.0/coprocessor/*&quot;</span>
</pre></div>
</div>
</li>
<li><p class="first">Restart HBase master and regionservers.</p>
</li>
<li><p class="first">Enable replication from master to slave:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">master_hbase_shell&gt; add_peer &#39;[slave-name]&#39;, &#39;[slave-zookeeper-quorum]:/[slave-zk-node]&#39;</span>

<span class="gp">#</span> For example:
<span class="go">master_hbase_shell&gt; add_peer &#39;slave&#39;, &#39;slave.example.com:2181:/hbase&#39;</span>
</pre></div>
</div>
</li>
<li><p class="first">Enable replication from slave to master:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">slave_hbase_shell&gt; add_peer &#39;[master-name]&#39;, &#39;[master-zookeeper-quorum]:/[master-zk-node]&#39;</span>

<span class="gp">#</span> For example:
<span class="go">slave_hbase_shell&gt; add_peer &#39;master&#39;, &#39;master.example.com:2181:/hbase&#39;</span>
</pre></div>
</div>
</li>
<li><p class="first">Confirm that HBase replication is working:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">master_hbase_shell&gt; create &#39;repltest&#39;, &#39;f&#39;</span>

<span class="go">slave_hbase_shell&gt; create &#39;repltest&#39;, &#39;f&#39;</span>

<span class="go">master_hbase_shell&gt; enable_table_replication &#39;repltest&#39;</span>

<span class="go">slave_hbase_shell&gt; alter &#39;repltest&#39;, { &#39;NAME&#39; =&gt; &#39;f&#39;, &#39;REPLICATION_SCOPE&#39; =&gt; 1 }</span>

<span class="go">master_hbase_shell&gt; put &#39;repltest&#39;, &#39;masterrow&#39;, &#39;f:v1&#39;, &#39;v1&#39;</span>

<span class="go">slave_hbase_shell&gt; put &#39;repltest&#39;, &#39;slaverow&#39;, &#39;f:v1&#39;, &#39;v1&#39;</span>

<span class="go">master_hbase_shell&gt; scan &#39;repltest&#39;</span>

<span class="go">slave_hbase_shell&gt; scan &#39;repltest&#39;</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="hdfs">
<h3>HDFS<a class="headerlink" href="#hdfs" title="Permalink to this headline">🔗</a></h3>
<p>Set up HDFS replication using the solution provided by your distribution. HDFS does not
have true replication, but it is usually achieved by scheduling regular <code class="docutils literal notranslate"><span class="pre">distcp</span></code> jobs.</p>
</div>
<div class="section" id="hive">
<h3>Hive<a class="headerlink" href="#hive" title="Permalink to this headline">🔗</a></h3>
<p>Set up replication for the database backing your Hive Metastore. Note that this will
simply replicate the Hive metadata—which tables exist, table metadata, etc.—but not the data itself. It is assumed you will not be running Hive queries on the slave
until after a manual failover occurs.</p>
<p>For example, to setup MySQL 5.7 replication, follow the steps described at
<a class="reference external" href="https://dev.mysql.com/doc/refman/5.7/en/replication-howto.html">Setting Up Binary Log File Position Based Replication</a>.</p>
</div>
<div class="section" id="kafka">
<h3>Kafka<a class="headerlink" href="#kafka" title="Permalink to this headline">🔗</a></h3>
<p>Set up replication for the Kafka brokers you are using. <em>Kafka MirrorMaker</em> is the most
common solution. See <a class="reference external" href="https://kafka.apache.org/documentation.html#basic_ops_mirror_maker">Mirroring data between clusters</a> and
<a class="reference external" href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27846330">Kafka mirroring (MirrorMaker)</a>
for additional information.</p>
</div>
</div>
<div class="section" id="cdap-setup">
<span id="installation-replication-cdap-setup"></span><h2>CDAP Setup<a class="headerlink" href="#cdap-setup" title="Permalink to this headline">🔗</a></h2>
<p>CDAP requires that you provide an extension that will perform HBase-related DDL operations
on both clusters instead of only on a single cluster. To create the extension, you must
implement the <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutor</span></code> class. Details on implementing this class, a sample
implementation, and example files are available in the <a class="reference internal" href="../appendices/hbase-ddl-executor.html#appendix-hbase-ddl-executor"><span class="std std-ref">Appendix: HBaseDDLExecutor</span></a>.</p>
<p>CDAP must have <a class="reference internal" href="#installation-replication-disable-invalid-transaction-list-pruning"><span class="std std-ref">invalid transaction list pruning disabled</span></a>, as this cannot be
used with replication.</p>
<p>To deploy your extension (once compiled and packaged as a JAR file, such as
<em>my-extension.jar</em>), run these steps on <strong>both</strong> your master and slave clusters.
These steps assume <code class="docutils literal notranslate"><span class="pre">&lt;cdap-home&gt;</span></code> is <code class="docutils literal notranslate"><span class="pre">/opt/cdap</span></code>:</p>
<ol class="arabic">
<li><p class="first">Create an extension directory, such as:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> mkdir -p /opt/cdap/master/ext/hbase/repl
</pre></div>
</div>
</li>
<li><p class="first">Copy your JAR to the directory:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> cp my-extension.jar /opt/cdap/master/ext/hbase/repl/
</pre></div>
</div>
</li>
<li><p class="first">Modify <code class="docutils literal notranslate"><span class="pre">cdap-site.xml</span></code> to use your implementation of <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutor</span></code>:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>hbase.ddlexecutor.extension.dir<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>/opt/cdap/master/ext/hbase<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Modify <code class="docutils literal notranslate"><span class="pre">cdap-site.xml</span></code> with any properties required by your executor. Any property prefixed
with <code class="docutils literal notranslate"><span class="pre">cdap.hbase.spi.hbase.</span></code> will be available through the
<code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutorContext</span></code> object passed into your executor’s initialize method:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>cdap.hbase.spi.hbase.zookeeper.quorum<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>slave.example.com:2181/cdap<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>cdap.hbase.spi.hbase.zookeeper.session.timeout<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>60000<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>cdap.hbase.spi.hbase.cluster.distributed<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>true<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>cdap.hbase.spi.hbase.bulkload.staging.dir<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>/tmp/hbase-staging<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
<span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>cdap.hbase.spi.hbase.replication<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>true<span class="nt">&lt;/value&gt;</span>
<span class="nt">&lt;/property&gt;</span>
</pre></div>
</div>
</li>
<li id="installation-replication-disable-invalid-transaction-list-pruning"><p class="first">Modify <code class="docutils literal notranslate"><span class="pre">cdap-site.xml</span></code> to <strong>disable invalid transaction list pruning,</strong> as it cannot
be used with replication:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;property&gt;</span>
  <span class="nt">&lt;name&gt;</span>data.tx.prune.enable<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;value&gt;</span>false<span class="nt">&lt;/value&gt;</span>
  <span class="nt">&lt;description&gt;</span>
    Enable invalid transaction list pruning
  <span class="nt">&lt;/description&gt;</span>
<span class="nt">&lt;/property&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Before starting CDAP on the master cluster, run a command on the slave cluster to load
the HBase coprocessors required by CDAP onto the slave’s HDFS:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[slave] $</span> cdap setup coprocessors
</pre></div>
</div>
</li>
<li><p class="first">Start CDAP on the master cluster:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[master] $</span> cdap master start
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="manual-failover-procedure">
<h2>Manual Failover Procedure<a class="headerlink" href="#manual-failover-procedure" title="Permalink to this headline">🔗</a></h2>
<p>To manually failover from the master to a slave cluster, follow these steps:</p>
<ol class="arabic">
<li><p class="first">Stop all CDAP programs on the master cluster</p>
</li>
<li><p class="first">Stop CDAP on the master cluster</p>
</li>
<li><p class="first">Copy any HDFS files that have not yet been copied using either your distro’s solution or <code class="docutils literal notranslate"><span class="pre">distcp</span></code></p>
</li>
<li><p class="first">Run the CDAP replication status tool to retrieve the cluster state:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[master] $</span> cdap run io.cdap.cdap.data.tools.ReplicationStatusTool -m -o /tmp/master_state
</pre></div>
</div>
</li>
<li><p class="first">Copy the master state onto your slave cluster:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[master] $</span> scp /tmp/master_state &lt;slave&gt;:/tmp/master_state
</pre></div>
</div>
</li>
<li><p class="first">Verify that replication has copied the required data onto the slave:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[slave] $</span> cdap run io.cdap.cdap.data.tools.ReplicationStatusTool -i /tmp/master_state
<span class="go">...</span>
<span class="go">Master and Slave Checksums match. HDFS Replication is complete.</span>
<span class="go">HBase Replication is complete.</span>
</pre></div>
</div>
</li>
<li><p class="first">Run Hive’s <code class="docutils literal notranslate"><span class="pre">metatool</span></code> to update the locations for the Hive tables:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[slave] $</span> hive --service metatool -updateLocation hdfs://<span class="o">[</span>slave-namenode-host<span class="o">]</span>:<span class="o">[</span>slave-namenode-port<span class="o">]</span> <span class="se">\</span>
             hdfs://<span class="o">[</span>master-namenode-host<span class="o">]</span>:<span class="o">[</span>master-namenode-port<span class="o">]</span> <span class="se">\</span>
             -tablePropKey avro.schema.url -serdePropKey avro.schema.url
</pre></div>
</div>
</li>
<li><p class="first">Start CDAP on the slave:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[slave] $</span> cdap master start
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="upgrading-replicated-clusters">
<h2>Upgrading Replicated Clusters<a class="headerlink" href="#upgrading-replicated-clusters" title="Permalink to this headline">🔗</a></h2>
<p>Consider a scenario where CDAP is running on the master cluster with data getting replicated on the slave cluter.
To upgrade the replicated clusters, follow these steps:</p>
<ol class="arabic simple">
<li>Update the CDAP repository definition on the slave cluster by running either of these methods:</li>
</ol>
<blockquote>
<div><ul>
<li><p class="first">On RPM using Yum:</p>
<div class="highlight container">
<pre class="literal-block">
<span class="gp">$</span> sudo curl -o /etc/yum.repos.d/cask.repo http://repository.cask.co/centos/6/x86_64/cdap/6.1/cask.repo
</pre>
</div>
<p>This will create the file <code class="docutils literal notranslate"><span class="pre">/etc/yum.repos.d/cask.repo</span></code> with:</p>
<pre class="literal-block">
[cask]
name=Cask Packages
baseurl=https://repository.cask.co/centos/6/x86_64/cdap/6.1
enabled=1
gpgcheck=1
</pre>
<p>Add the Cask Public GPG Key to your repository:</p>
<div class="highlight container">
<pre class="literal-block">
<span class="gp">$</span> sudo rpm --import http://repository.cask.co/centos/6/x86_64/cdap/6.1/pubkey.gpg
</pre>
</div>
<p>Update your Yum cache:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo yum makecache
</pre></div>
</div>
</li>
<li><p class="first">On Debian using APT:</p>
<div class="highlight container">
<pre class="literal-block">
<span class="gp">$</span> sudo curl -o /etc/apt/sources.list.d/cask.list http://repository.cask.co/ubuntu/precise/amd64/cdap/6.1/cask.list
</pre>
</div>
<p>This will create the file <code class="docutils literal notranslate"><span class="pre">/etc/apt/sources.list.d/cask.list</span></code> with:</p>
<pre class="literal-block">
deb [ arch=amd64 ] http://repository.cask.co/ubuntu/precise/amd64/cdap/6.1 precise cdap
</pre>
<p>Add the Cask Public GPG Key to your repository:</p>
<div class="highlight container">
<pre class="literal-block">
<span class="gp">$</span> curl -s http://repository.cask.co/ubuntu/precise/amd64/cdap/6.1/pubkey.gpg | sudo apt-key add -
</pre>
</div>
<p>Update your APT-cache:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo apt-get update
</pre></div>
</div>
</li>
</ul>
</div></blockquote>
<ol class="arabic simple" start="2">
<li>Update the CDAP packages on the slave cluster by running either of these methods:</li>
</ol>
<blockquote>
<div><ul>
<li><p class="first">On RPM using Yum:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo yum upgrade <span class="s1">&#39;cdap*&#39;</span>
</pre></div>
</div>
</li>
<li><p class="first">On Debian using APT:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo apt-get install --only-upgrade <span class="s1">&#39;^cdap.*&#39;</span>
</pre></div>
</div>
</li>
</ul>
</div></blockquote>
<ol class="arabic" start="3">
<li><p class="first">Generate the coprocessor jar on the slave cluster corresponding to the newly downloaded CDAP version:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo -u &lt;cdap-user&gt; cdap setup coprocessors
</pre></div>
</div>
<p>The coprocessor jar will be stored on the HDFS and path to the jar will be printed on console.</p>
</li>
<li><p class="first">Copy the coprocessor jar to the same HDFS location on the master cluster.</p>
</li>
<li><p class="first">Stop all CDAP services on the master cluster.</p>
</li>
<li><p class="first">Make sure that all HBase and HDFS data is replicated on the slave cluster.</p>
</li>
<li><p class="first">Run the upgrade tool on the slave cluster.:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> sudo -u &lt;cdap-user&gt; /opt/cdap/master/bin/cdap run io.cdap.cdap.data.tools.UpgradeTool upgrade
</pre></div>
</div>
<p>Since replication is enabled and HBaseDDLExecutor is in place, HBase tables on the master cluster will also get
upgraded.</p>
</li>
<li><p class="first">New version of the CDAP can be started on the slave cluster now.</p>
</li>
<li><p class="first">Download and install the new CDAP packages on the master cluster using the steps mentioned above for slave. This is to keep the master ready when there is a failover from slave. Note that there is no need to run the upgrade tool on the master since HBase tables on master were already upgraded when the upgrade tool was executed on the slave.</p>
</li>
</ol>
</div>
</div>

</div>
    <div class="col-md-2">
      <div id="right-sidebar" class="bs-sidenav scrollable-y" role="complementary">
        <div id="localtoc-scrollspy">
        </div>
      </div>
    </div></div>
</div>
<!-- block main content end -->
<!-- block footer -->
<footer class="footer">
      <div class="container">
        <div class="row">
          <div class="col-md-2 footer-left"><a title="Manual Installation using Packages" href="packages.html" />Previous</a></div>
          <div class="col-md-8 footer-center"><a class="footer-tab-link" href="../table-of-contents/../../reference-manual/licenses/index.html">Copyright</a> &copy; 2014-2020 Cask Data, Inc.&bull; <a class="footer-tab-link" href="//docs.cask.co/cdap/6.1.1/cdap-docs-6.1.1-web.zip" rel="nofollow">Download</a> an archive or
<a class="footer-tab-link" href="//docs.cask.co/cdap">switch the version</a> of the documentation
          </div>
          <div class="col-md-2 footer-right">&mdash;</div>
        </div>
      </div>
    </footer>
<!-- block footer end -->
<script type="text/javascript" src="../_static/bootstrap-3.3.6/js/bootstrap.min.js"></script><script type="text/javascript" src="../_static/js/bootstrap-sphinx.js"></script><script type="text/javascript" src="../_static/js/abixTreeList-2.js"></script><script type="text/javascript" src="../_static/js/cdap-dynamicscrollspy-4.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script><script type="text/javascript" src="../_static/js/copy-to-clipboard.js"></script><script type="text/javascript" src="../_static/js/jquery.mousewheel.min.js"></script><script type="text/javascript" src="../_static/js/jquery.mCustomScrollbar.js"></script><script type="text/javascript" src="../_static/js/js.cookie.js"></script><script type="text/javascript" src="../_static/js/tabbed-parsed-literal-0.2.js"></script><script type="text/javascript" src="../_static/js/cdap-onload-javascript.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script>
    <script src="https://cdap.gitee.io/docs/cdap/json-versions.js"/></script>
  </body>
</html>